<template>
  <div class="WorkingSchedule" v-loading="loading">
    <el-form ref="form" :model="form" label-position="top" class="myform">
      <div>
        <el-form-item label="RFID编码" class="myform-item">
          <el-input
            v-model="form.number"
            placeholder="请输入RFID编码"
            @keyup.enter.native="onSearch"
            clearable
          ></el-input>
        </el-form-item>
        <el-form-item label="扫码时间">
          <el-date-picker
            value-format="yyyy-MM-dd"
            v-model="form.createtime"
            type="daterange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
          >
          </el-date-picker>
        </el-form-item>
      </div>
      <div>
        <el-form-item style="margin-top: 50px">
          <el-button type="primary" @click="onSearch">查询</el-button>
          <!-- <el-button type="primary">导出</el-button>
          <el-button type="primary">上传文件</el-button> -->
        </el-form-item>
      </div>
    </el-form>
    <el-table :data="tableData" style="width: 100%" border>
      <el-table-column label="昵称/头像" align="center" prop="nickname">
        <template slot-scope="{ row }">
          <div v-if="row.nickname">
            
            <img
              :src="row.avatarurl"
              style="width: 80px; height: 80px"
              alt=""
              srcset=""
            />
            <div>{{ row.nickname }}</div>
          </div>
        </template>
      </el-table-column>
      <el-table-column label="RFID编码" align="center" prop="number">
      </el-table-column>
      <el-table-column label="扫码时间" align="center" prop="createtime">
      </el-table-column>
      <el-table-column label="编码状态" align="center" prop="status">
        <template slot-scope="{ row }">
          {{
            row.status == 0
              ? "正常"
              : row.status == 0
              ? "正常"
              : row.status == 1
              ? "格式长度错误的码"
              : "格式正确，但无信息"
          }}
        </template>
      </el-table-column>
      <el-table-column label="请求IP" align="center" prop="request_ip">
      </el-table-column>
      <el-table-column label="来源" align="center" prop="source">
          <template slot-scope="{ row }">
          {{
            row.source == 1
              ? "微信"
              : "淘宝"
              
          }}
        </template>
      </el-table-column>
    </el-table>
    <pagination
      :form="form"
      :total="total"
      @paginationPostOrderTaskList="postAdminCodeGetScancodelog"
    />
  </div>
</template>

<script>
import { postAdminCodeGetScancodelog } from "@/api";
import pagination from "@/components/pagination.vue";
export default {
  components: { pagination },
  data() {
    return {
      loading: false,
      date: "",
      form: {
          number:"",
          createtime:"",
        page: 1,
        size: 10,
      },
      tableData: [],
      total: 1,
    };
  },
  activated() {
    let form = this.form;
    this.postAdminCodeGetScancodelog(form);
  },
  methods: {
    // 编辑
    onEdit(e) {
      console.log("编辑", e);
      this.detail = e;
      this.dialogVisible = true;
    },
    // 采购列表
    async postAdminCodeGetScancodelog(data) {
      this.loading = true;
      this.form = data;
      let form = JSON.parse(JSON.stringify(this.form));
      if (form.createtime) {
        form.createtime = `${form.createtime[0]}/${form.createtime[1]}`;
      }
      postAdminCodeGetScancodelog(form)
        .then((res) => {
          this.loading = false;
          console.log("采购列表", res);
          this.tableData = res.data;
          this.total = Number(res.total);
        })
        .catch((err) => {
          this.loading = false;
        });
    },
    // 搜索
    onSearch() {
      this.form.page = 1;
      this.form.size = 10;
      this.postAdminCodeGetScancodelog(this.form);
    },
  },
};
</script>

<style lang="scss" scoped>
.myform {
  display: flex;
  justify-content: space-between;
  > div {
    display: flex;
  }
  &-item {
    margin-right: 10px;
  }
}
.WorkingSchedule {
  background: #ffff;
  padding: 20px;
  border-radius: 2px;
  @include boxShadow;
}
</style>
